<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<jsp:include page="/includes/top.jsp"></jsp:include>
<div class="page-header">
	<h1></h1>
</div>
<!-- /.page-header -->
<div class="row">
	<div class="col-xs-12">
		<form class="form-horizontal" id="tasklogForm">
			<div style="display: none">
				<input type="hidden" name="tasklog.taskLogId" value="${tasklog.taskLogId}" /> 
				<input type="hidden" name="tasklog.taskId" value="${tasklog.taskId}" />
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right">日志名称:</label>
				<div class="col-sm-4">
					<div class="clearfix input-icon input-icon-right">
						<input type="text" class="form-control" name="tasklog.taskLogName"
							placeholder="日志名称" value="${tasklog.taskLogName}" />
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right">日志描述:</label>
				<div class="col-sm-4">
					<div class="clearfix input-icon input-icon-right">
						<textarea class="form-control" name="tasklog.taskLogDescription"
							placeholder="任务描述" rows="6">${tasklog.taskLogDescription}</textarea>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right">更新进度:</label>
				<div class="col-sm-4">
					<div class="clearfix input-icon input-icon-right">
						<input type="text" class="form-control"
							value="${tasklog.taskLogPercent}" name="tasklog.taskLogPercent"
							placeholder="进度%" />
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label no-padding-right">日志类型:</label>
				<div class="col-sm-4">
					<div class="clearfix input-icon input-icon-right">
						<s:select cssClass="form-control" id="logtype"
							name="tasklog.taskLogType" list="#{'0':'一般日志','1':'问题报告'}"
							listValue="value" listKey="key" value="tasklog.taskLogType"></s:select>
					</div>
				</div>
			</div>
			<div class="clearfix form-actions">
				<div class="col-md-offset-3 col-md-9">
					<button class="btn btn-info" id="save" type="button">
						<i class="icon-ok"></i> 保存
					</button>

					&nbsp; &nbsp; &nbsp;
					<button class="btn" type="reset" id="back">
						<i class="icon-undo"></i> 取消
					</button>
				</div>
			</div>
		</form>
	</div>
	<!-- /.col -->
</div>
<jsp:include page="/includes/bottom.jsp"></jsp:include>

<script type="text/javascript">
	var lid = getQueryString("tasklog.taskLogId");
	function savafrom(url) {
		$("#save").click(function() {
			$("#tasklogForm").bootstrapValidator("validate");
			if ($("#tasklogForm").data("bootstrapValidator").isValid()) {
				var dataMap = $("#tasklogForm").serializeArray();
				$.ajax({
					type : "post",
					url : url,
					data : dataMap,
					success : function(data) {
						window.history.back();
					}
				});
			}
		});
	}
	$(document).ready(function() {
		if (lid != null && lid != "") {
			savafrom("edittasklog");
		} else {
			savafrom("addtasklog");
		}
		$("#back").click(function() {
			window.history.back();
		});
		$("#tasklogForm").bootstrapValidator({
			feedbackIcons : {
				valid : 'icon-ok-sign',
				invalid : 'icon-remove-sign',
				validating : 'icon-refresh'
			},
			fields : {
				'tasklog.taskLogName' : {
					validators : {
						notEmpty : {
							message : '日志名称，不能为空！'
						}
					}
				},
				'tasklog.taskLogDescription' : {
					validators : {
						notEmpty : {
							message : '日志描述，不能为空！'
						}
					}
				},
				'tasklog.taskLogPercent' : {
					validators : {
						regexp: {
	                        regexp: /^[0-9_\.]+$/,
	                        message: '只能输入数字'
	                    },
						greaterThan : {
							value : 0,
							inclusive : true,
							message : '最小值0'
						},
						lessThan : {
							value : 100,
							inclusive : true,
							message : '最大值100'
						}
					}
				}
			}
		});
	});
</script>
